<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>股票交易模拟登录</title>
    <link rel="icon" type="image/x-icon" href="/img/favicon.gif"/>
</head>
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/ui/Input.css">
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/ui/Placeholder.css">
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/ui/Button.css">
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/animate.css">
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/ui.css">
<link rel="stylesheet" href="/static/css/mockup.css">
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/ui/Button.css">
<link rel="stylesheet" href="https://qidian.gtimg.com/lulu/pure/css/common/ui/Dialog.css">
<script src="https://qidian.gtimg.com/lulu/pure/js/common/ui/Dialog.js"></script>
<script src="https://qidian.gtimg.com/c/=/lulu/theme/pure/js/common/ui/Follow.js,/lulu/theme/pure/js/common/ui/ErrorTip.js,/lulu/theme/pure/js/common/ui/Validate.js"></script>
<style>
    .div-input{
        margin-top: 1%;
        margin-left: 30%;
    }
</style>
<body>
<section style="width: 100%;height:calc(20% - 2px);background-color: white">
    <p align="center">
        <img style="width: 300px;height: 100px" src="/img/07.jfif">
    </p>
    <p align="center" style="color: #f59b00">金融交易模拟教学平台 </p>
<!--    <img style="width: 100%;height: 60%" src="/img/07.jfif">-->
</section>
<section align="center" style="width: 75%;">
    <form  action="/login/action" method="post" id="form" style="margin-top: 3%;width: 100%;" >
        <div class="div-input">
            <label class="left f14" >用名</label>
            <input type="text" id="name"  class="ui-input" size="50" name="name" required>
        </div>
        <div class="div-input">
            <label class="left f14" >密码</label>
            <input type="password"  id="passWord" class="ui-input" size="50" name="passWord" required>
        </div>
        <div class="div-input" >
            <button  type="button" onclick="send()" class="ui-button" style="margin: 3px;" data-type="primary">登录</button>
            <a class="ui-button" href="/user/add">注册</a>
        </div>
    </form>
</section>

<footer style="margin-top: 15%">
    <p style="color: gray;font-family: Calibri;" align="center">备案号：鲁ICP备16042233号 联系我们: <a style="color: black" href="mailto:sunyuanlong@bbs-step.com">surport@bbs-step.com</a>.</p>
</footer>
</body>

<script>
    function send() {
        //创建异步对象
        var xhr = new XMLHttpRequest();
        //设置请求的类型及url
        xhr.open('post', '/login/action',true);
        //post请求一定要添加请求头才行不然会报错
        xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        //发送请求
        var data = $("#form").serialize();
        // xmlHttp.send('{"name":"moses","age":22}') ;   // 请求体数据
        console.log(data);
        xhr.send(data);
        xhr.onreadystatechange = function () {
            // 这步为判断服务器是否正确响应
            if (xhr.readyState == 4 && xhr.status == 200) {
                console.log(xhr.responseText);
                var re = JSON.parse(xhr.responseText);
                if(re.code == 200 ){
                    // new Dialog().alert('操作成功！', {
                    //     type: 'success'
                    // });
                    setTimeout(window.location = "/",0);
                }else{
                    new Dialog().alert(re.msg, {
                        type: 'failure'
                    });
                }
            }
        };
    }


</script>

</html>